package com.ssm.job;

import com.hbase.ApplicationConfig;
import com.sitech.common.utils.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * @ClassName ScheduleJob
 * @Description TODO
 * @Author zhurs
 * @Date 2019/10/14  17:12
 * @Version 1.0
 **/
public class ScheduleJob extends QuartzJobBean {

    protected static final Logger logger = Logger.getLogger(MyJob.class);


    @Override
    protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
        logger.info("Myjob开始执行了。。。。"+arg0.getTrigger().getKey().getName());
        ApplicationContext applicationContext=(ApplicationContext)arg0.getJobDetail().getJobDataMap()
                .get("applicationContext");


    }

    public static void executeGet(String url)
    {
        HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet(url);
        try {
            HttpResponse res = client.execute(get);
            if (res.getStatusLine().getStatusCode() == 200) {

            }
//          HttpEntity localHttpEntity = res.getEntity();
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
        finally
        {
            client.getConnectionManager().shutdown();
        }
    }
}
